#pragma once

#include <memory>
#include <mutex>

//__declspec(dllexport)
template <class T> class SingleTon
{
public:
	static T* getInstance()
	{
		if (m_instance == NULL)
		{
			m_Mutex.lock();
			if (m_instance == NULL)
			{
				m_instance = std::shared_ptr<T>(new T());
			}
			m_Mutex.unlock();
		}

		return m_instance.get();
	}

protected:
	explicit SingleTon() {}
	static std::mutex m_Mutex;
	static std::shared_ptr<T> m_instance;
};

template <class T>
std::shared_ptr<T> SingleTon<T>::m_instance(NULL);

template <class T>
std::mutex SingleTon<T>::m_Mutex;

